home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 API Bible / Windows 95 API Bible 3 Disc Set.iso / Win32 API Bible Book 3 of 3 / CHAPTE11 / CONFIGDG / PHONE.C < prev    next >
C/C++ Source or Header  |  1996-04-28  |  20KB  |  614 lines

  1. #include <windows.h> 
  2. #include <windowsx.h> 
  3. #include "phone.h" 
  4. #include "tapi.h"
  5.  
  6. #define BUFSIZE 256
  7. #define APIHIVERSION     0x00010028    /* 1.40 */
  8. #define APILOWVERSION    0x00010000    /* 1.0 */
  9. #define EXTHIVERSION     0x00010005    /* 1.5 */
  10. #define EXTLOWVERSION    0x00000009    /* 0.9 */ 
  11. #define MAX_PHONE        2
  12. #define OWNER            0
  13. #define MONITOR        1
  14.  
  15. LPCTSTR lpszAppName = "phoneConfigDialog";
  16. LPCTSTR lpszTitle   = "phoneConfigDialog"; 
  17.  
  18.  
  19. #if defined (WIN32)
  20.     #define IS_WIN32 TRUE
  21. #else
  22.     #define IS_WIN32 FALSE
  23. #endif
  24.  
  25. #define IS_NT      IS_WIN32 && (BOOL)(GetVersion() < 0x80000000)
  26. #define IS_WIN32S  IS_WIN32 && (BOOL)(!(IS_NT) && (LOBYTE(LOWORD(GetVersion()))<4))
  27. #define IS_WIN95   (BOOL)(!(IS_NT) && !(IS_WIN32S)) && IS_WIN32
  28.  
  29. HINSTANCE hInst;   // current instance
  30. HWND hWnd;         // parent window handle
  31. HWND hListWnd;     // listbox
  32. HDC  hdc;
  33. TEXTMETRIC  tm ;
  34.  
  35. BOOL RegisterWin95( CONST WNDCLASS* lpwc );
  36.  
  37.  
  38. int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
  39.                       LPTSTR lpCmdLine, int nCmdShow)
  40. {
  41.    MSG      msg;
  42.    WNDCLASS wc;
  43.  
  44.    wc.style         = CS_HREDRAW | CS_VREDRAW;
  45.    wc.lpfnWndProc   = (WNDPROC)WndProc;       
  46.    wc.cbClsExtra    = 0;                      
  47.    wc.cbWndExtra    = 0;                      
  48.    wc.hInstance     = hInstance;              
  49.    wc.hIcon         = LoadIcon (hInstance, lpszAppName); 
  50.    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
  51.    wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
  52.    wc.lpszMenuName  = lpszAppName;              
  53.    wc.lpszClassName = lpszAppName;              
  54.  
  55.    if ( IS_WIN95 )
  56.    {
  57.       if ( !RegisterWin95( &wc ) )
  58.          return( FALSE );
  59.    }
  60.    else if ( !RegisterClass( &wc ) )
  61.       return( FALSE );
  62.  
  63.    hInst = hInstance; 
  64.  
  65.    hWnd = CreateWindow( lpszAppName, 
  66.                         lpszTitle,    
  67.                         WS_OVERLAPPEDWINDOW, 
  68.                         CW_USEDEFAULT, 0, 
  69.                         CW_USEDEFAULT, 0,  
  70.                         NULL,              
  71.                         NULL,              
  72.                         hInstance,         
  73.                         NULL               
  74.                       );
  75.  
  76.    if ( !hWnd ) 
  77.       return( FALSE );
  78.  
  79.    ShowWindow( hWnd, nCmdShow ); 
  80.    UpdateWindow( hWnd );         
  81.  
  82.    while( GetMessage( &msg, NULL, 0, 0) )   
  83.    {
  84.       TranslateMessage( &msg ); 
  85.       DispatchMessage( &msg );  
  86.    }
  87.  
  88.    return( msg.wParam ); 
  89. }
  90.  
  91.  
  92. BOOL RegisterWin95( CONST WNDCLASS* lpwc )
  93. {
  94.     WNDCLASSEX wcex;
  95.  
  96.    wcex.style         = lpwc->style;
  97.    wcex.lpfnWndProc   = lpwc->lpfnWndProc;
  98.    wcex.cbClsExtra    = lpwc->cbClsExtra;
  99.    wcex.cbWndExtra    = lpwc->cbWndExtra;
  100.    wcex.hInstance     = lpwc->hInstance;
  101.    wcex.hIcon         = lpwc->hIcon;
  102.    wcex.hCursor       = lpwc->hCursor;
  103.    wcex.hbrBackground = lpwc->hbrBackground;
  104.    wcex.lpszMenuName  = lpwc->lpszMenuName;
  105.    wcex.lpszClassName = lpwc->lpszClassName;
  106.  
  107.    // Added elements for Windows 95.
  108.    //...............................
  109.    wcex.cbSize = sizeof(WNDCLASSEX);
  110.    wcex.hIconSm = LoadImage(wcex.hInstance, lpwc->lpszClassName, 
  111.                             IMAGE_ICON, 16, 16,
  112.                             LR_DEFAULTCOLOR );
  113.             
  114.    return RegisterClassEx( &wcex );
  115. }
  116.  
  117. typedef struct tagMYINFO    // general application information
  118. {
  119.     HPHONEAPP phoneApp;      // instance handle TAPI gives back to us                                                                              through phoneInitialize()
  120.     DWORD dwNumDevices;     // number of available devices
  121.     DWORD dwAPIVersion;     // API version the phone supports
  122.     DWORD dwExtVersion;        // extended version
  123. } MYINFO;
  124.  
  125. typedef struct tagPHONEINFO  // information on an open phone
  126. {
  127.    HPHONE     hPhone;           // handle to the phone as returned by phoneOpen 
  128.     DWORD      dwDeviceID;            // device ID of the phone device
  129.     DWORD        dwRequestID;
  130.     char       szPhoneName[128]; // the phone's name 
  131. }PHONEINFO;
  132.  
  133. MYINFO myInfo;          //instance of MYINFO structure
  134. PHONEINFO myPhoneInfo[MAX_PHONE];  //instance of myPhoneInfo structure
  135.  
  136. LONG lRet;        //return code
  137. char buf[BUFSIZE];    // buffer for debug message
  138. char DataBuf[BUFSIZE]; //get/set data buffer;
  139.  
  140. DWORD i;
  141. DWORD dwHookSwitchDevs;
  142. DWORD dwLampMode;
  143. DWORD dwRingMode;
  144. DWORD dwRingVolume;
  145. DWORD dwHookSwitchVolume;
  146. DWORD dwPhoneStates;
  147. DWORD dwButtonModes;
  148. DWORD dwButtonStates;
  149. DWORD dwGain;
  150. HICON hIcon;
  151.  
  152. LONG lRet;
  153. char buf[BUFSIZE];
  154.  
  155. PHONECAPS*             pPhoneCaps;
  156. PHONEBUTTONINFO*  pButtonInfo;
  157. VARSTRING*            pVarString;
  158. PHONESTATUS*        pPhoneStatus;
  159. PHONEEXTENSIONID    ext_id;                                             
  160.  
  161.  
  162. LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
  163. {
  164.    switch( uMsg )
  165.    {
  166.       case WM_COMMAND :
  167.          switch( LOWORD( wParam ) )
  168.          {
  169.             case IDM_RUN  :
  170.                 lRet = phoneConfigDialog(0, hWnd, "tapi/phone");
  171.                    if (lRet == 0)
  172.                   {
  173.                   wsprintf(buf, "phoneConfigDialog succeeded!");
  174.                   SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;               
  175.                }
  176.                    else 
  177.                    {
  178.                        wsprintf( buf,"phoneConfigDialog failed, err=x%lx", lRet);
  179.                        phoneError(lRet);
  180.                }       
  181.                   break;
  182.          
  183.             case IDM_EXIT :
  184.                for (i = 0; i < myInfo.dwNumDevices; i++)
  185.                     phoneClose(myPhoneInfo[i].hPhone);
  186.                 
  187.                    phoneShutdown(myInfo.phoneApp);
  188.                DestroyWindow( hWnd );
  189.                break;
  190.  
  191.             case IDM_ABOUT :
  192.                 DialogBox( hInst, "AboutBox", hWnd, (DLGPROC)About );
  193.                 break;
  194.          
  195.          }
  196.                 
  197.             return( DefWindowProc( hWnd, uMsg, wParam, lParam ) );
  198.  
  199.       
  200.        case WM_CREATE :
  201.  
  202.           hdc = GetDC (hWnd) ;
  203.           GetTextMetrics (hdc, &tm) ;
  204.           ReleaseDC (hWnd, hdc) ;
  205.            
  206.           hListWnd = CreateWindowEx( 0, "listbox", 
  207.                         " ",    
  208.                         WS_CHILD | WS_VISIBLE,  
  209.                         tm.tmAveCharWidth, tm.tmHeight * 3, 
  210.                         tm.tmAveCharWidth * 16 +
  211.                                    GetSystemMetrics (SM_CXVSCROLL), 
  212.                         tm.tmHeight * 5,  
  213.                         hWnd,              
  214.                         NULL,              
  215.                         hInst,         
  216.                         NULL               
  217.                         );
  218.       
  219.              //phoneInitialize
  220.                //...............................................
  221.             lRet = phoneInitialize(&myInfo.phoneApp, hInst, phoneCallback, lpszAppName, &myInfo.dwNumDevices);
  222.             if (lRet == 0) 
  223.             {
  224.                 
  225.                wsprintf(buf, "phoneInitialize succeeded!");
  226.                    SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  227.             }
  228.                
  229.                else 
  230.                {
  231.                    wsprintf( buf,"phoneInitialize failed, err=x%lx",lRet);
  232.                SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  233.                     phoneError(lRet);
  234.                     break;
  235.             }                    
  236.                
  237.             //phoneNegotiateAPIVersion
  238.                   //...............................................
  239.             lRet = phoneNegotiateAPIVersion(myInfo.phoneApp, 0, APILOWVERSION, APIHIVERSION, 
  240.                                                     &myInfo.dwAPIVersion, &ext_id);
  241.             if (lRet == 0)                        
  242.             {
  243.                wsprintf(buf, "phoneNegotiateAPIVersion succeeded!");
  244.                       SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  245.             }
  246.                   else 
  247.                   {
  248.                    wsprintf(buf, "phoneNegotiateAPIVersion failed, err=x%lx", lRet);
  249.                     SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  250.                     phoneError(lRet);
  251.                     phoneShutdown(myInfo.phoneApp);
  252.                break;
  253.              }
  254.  
  255.                //phoneNegotiateExtVersion
  256.                //...............................................
  257.             lRet = phoneNegotiateExtVersion(myInfo.phoneApp, 0, myInfo.dwAPIVersion, EXTLOWVERSION, 
  258.                                                 EXTHIVERSION, &myInfo.dwExtVersion);
  259.             if (lRet == 0)                        
  260.             {
  261.                     wsprintf(buf, "phoneNegotiateExtVersion succeeded!");
  262.                SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  263.               }
  264.                   else 
  265.                {
  266.                     wsprintf(buf, "phoneNegotiateExtVersion failed, err=x%lx", lRet);
  267.                       SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  268.                       phoneError(lRet);
  269.                }
  270.  
  271.             //phoneOpen
  272.                //................................................................
  273.                for (i = 0; i < myInfo.dwNumDevices; i++)
  274.                {
  275.                    if ( i == 0)
  276.                        lRet = phoneOpen(myInfo.phoneApp,i,&myPhoneInfo[i].hPhone,
  277.                                  myInfo.dwAPIVersion,0,(DWORD)phoneCallback, PHONEPRIVILEGE_OWNER);
  278.                    else
  279.                        lRet = phoneOpen(myInfo.phoneApp,i,&myPhoneInfo[i].hPhone,
  280.                                  myInfo.dwAPIVersion,0,(DWORD)phoneCallback, PHONEPRIVILEGE_MONITOR);
  281.                    
  282.                    if (lRet == 0)
  283.                    {
  284.                      wsprintf(buf, "phoneOpen succeeded!");
  285.                         SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  286.                   pPhoneCaps = (PHONECAPS *) calloc (1, sizeof(PHONECAPS)+1000);
  287.                       pPhoneCaps->dwTotalSize = sizeof(PHONECAPS) + 1000;
  288.                          
  289.                       phoneGetDevCaps(myInfo.phoneApp,i,
  290.                       myInfo.dwAPIVersion, myInfo.dwExtVersion, pPhoneCaps);
  291.                       strcpy(buf, ((LPSTR)(pPhoneCaps)+pPhoneCaps->dwProviderInfoOffset));
  292.                   strcat( buf, " is the phone providor's name." );
  293.                   SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  294.                   strcpy(buf, ((LPSTR)(pPhoneCaps)+pPhoneCaps->dwPhoneNameOffset));
  295.                      
  296.                   if (i == 0)
  297.                   {
  298.                      strcat( buf, " is the phone's name opened with OWNER privilege." );
  299.                      SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  300.                   }
  301.                   else
  302.                   {
  303.                      strcat( buf, " is the phone's name opened with MONITOR privilege." );
  304.                      SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  305.                   }
  306.                }
  307.                    else 
  308.                    {
  309.                        wsprintf( buf,"phoneOpen failed, err=x%lx", lRet);
  310.                        phoneError(lRet);
  311.                       break;
  312.                }
  313.                   } 
  314.  
  315.             break;
  316.       
  317.       case WM_SIZE:
  318.           MoveWindow(hListWnd,0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
  319.          break;
  320.  
  321.       case WM_DESTROY :
  322.          PostQuitMessage(0);
  323.          break;
  324.             
  325.       default :
  326.             return( DefWindowProc( hWnd, uMsg, wParam, lParam ) );
  327.    }
  328.  
  329.    return( 0L );
  330. }
  331.  
  332.  
  333.  
  334.  
  335. /****************************************************************************
  336.     FUNCTION: phoneCallback
  337.     PURPOSE:  callback function handles phone events
  338. ****************************************************************************/
  339. LRESULT CALLBACK phoneCallback (DWORD  dwDevice, DWORD dwMsg,
  340.                                 DWORD dwCallbackInst, DWORD dwParam1,
  341.                                 DWORD dwParam2,DWORD dwParam3)
  342. {
  343.     
  344.     switch (dwMsg)
  345.     {
  346.         case PHONE_REPLY:
  347.             if (dwParam1 == myPhoneInfo[OWNER].dwRequestID) 
  348.                    if (dwParam2 != 0)
  349.                 {
  350.                        wsprintf( buf,"Function failed, err=x%lx", lRet);
  351.                        phoneError(lRet);
  352.                     SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  353.                    }
  354.             break;       
  355.  
  356.         case PHONE_STATE:
  357.         
  358.             if (dwParam1 == PHONESTATE_RINGMODE)
  359.             {
  360.                 lRet = phoneGetRing(myPhoneInfo[OWNER].hPhone, &dwRingMode, &dwRingVolume);
  361.                 if (lRet == 0)
  362.                {
  363.                 wsprintf(buf, "phoneGetRing succeeded!");
  364.                    SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  365.                if (dwRingMode == 0)
  366.                     {
  367.                         wsprintf(buf, "The phone device is currently not ringing.");
  368.                         SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  369.                }
  370.                     else
  371.                     {
  372.                         wsprintf(buf, "The phone is ringing with a Ring Mode pattern of x%lx", dwRingMode);
  373.                         SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  374.                    wsprintf(buf, "The phnes's Ring Volume is x%lx", dwRingVolume);
  375.                         SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  376.                     }
  377.                }
  378.                  else 
  379.                {
  380.                     wsprintf( buf,"phoneGetRing failed, err=x%lx", lRet);
  381.                    phoneError(lRet);
  382.                }        
  383.               
  384.               break;
  385.               }
  386.             
  387.  
  388.             if (dwParam1 == PHONESTATE_SPEAKERHOOKSWITCH)
  389.             {   
  390.                 lRet = phoneGetHookSwitch(myPhoneInfo[OWNER].hPhone, &dwHookSwitchDevs);
  391.                 if (lRet == 0)
  392.                {
  393.                wsprintf(buf, "phoneGetHookSwitch succeeded!");
  394.                       SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  395.                
  396.                if (dwHookSwitchDevs & PHONEHOOKSWITCHDEV_SPEAKER)
  397.                     {
  398.                         wsprintf(buf, "The phone's HookSwitch Speaker is offhook!");
  399.                        SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  400.                     }
  401.                     else
  402.                     {
  403.                    wsprintf(buf, "The phone's HookSwitch Speaker is onhook!");
  404.                         SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  405.                     }
  406.  
  407.               }
  408.                  else 
  409.                {
  410.                       wsprintf( buf,"phoneGetHookSwitch failed, err=x%lx", lRet);
  411.                    phoneError(lRet);
  412.                }    
  413.             break;                
  414.             }
  415.  
  416.             if (dwParam1 == PHONESTATE_SPEAKERVOLUME)
  417.             {   
  418.                 lRet = phoneGetVolume(myPhoneInfo[OWNER].hPhone, PHONEHOOKSWITCHDEV_SPEAKER, &dwHookSwitchVolume);
  419.                if (lRet == 0)
  420.                {
  421.                 wsprintf(buf, "phoneGetVolume succeeded!");
  422.                    SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  423.                wsprintf(buf, "The current volume for the Speaker Hookswitch is x%lx", dwHookSwitchVolume);
  424.                     SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  425.                }
  426.                  else 
  427.                {
  428.                     wsprintf( buf,"phoneGetVolume failed, err=x%lx", lRet);
  429.                    phoneError(lRet);
  430.                }    
  431.             break;                
  432.             }
  433.  
  434.             if (dwParam1 == PHONESTATE_SPEAKERGAIN)
  435.             {   
  436.                 lRet = phoneGetGain(myPhoneInfo[OWNER].hPhone, PHONEHOOKSWITCHDEV_SPEAKER, &dwGain);
  437.                 if (lRet == 0)
  438.                {
  439.                   wsprintf(buf, "phoneGetGain succeeded!");
  440.                       SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  441.                     wsprintf(buf, "The current Gain is x%lx", dwGain);
  442.                     SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  443.                }
  444.                  else 
  445.                {
  446.                       wsprintf( buf,"phoneGetGain failed, err=x%lx", lRet);
  447.                     phoneError(lRet);
  448.                }
  449.             break;                
  450.             }
  451.             
  452.             if (dwParam1 == PHONESTATE_DISPLAY)
  453.             {   
  454.                 pVarString = (VARSTRING *) calloc (1, sizeof(VARSTRING)+1000);
  455.                 pVarString->dwTotalSize = sizeof(VARSTRING) + 1000;
  456.                 lRet = phoneGetDisplay(myPhoneInfo[OWNER].hPhone, pVarString);
  457.                 if (lRet == 0)
  458.                {
  459.                   wsprintf(buf, "phoneGetDisplay succeeded!");
  460.                       SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  461.                strcpy(buf, lpszTitle);
  462.                //strcpy(buf, ((LPSTR)(pVarString)+pVarString->dwStringOffset));
  463.                strcat( buf, " is the current phone display." );
  464.                SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  465.                }
  466.                  else 
  467.                {
  468.                    wsprintf( buf,"phoneGetDisplay failed, err=x%lx", lRet);
  469.                   phoneError(lRet);
  470.                }    
  471.                     
  472.                 free (pVarString);
  473.                 break;
  474.               }
  475.    }
  476.    return (TRUE);
  477.  
  478.  
  479. /****************************************************************************
  480.     FUNCTION: phoneError
  481.     PURPOSE:  phone error messages
  482. ****************************************************************************/
  483. void phoneError (LONG lrc)
  484. {
  485.  switch (lrc) {
  486.     case PHONEERR_INVALAPPHANDLE:
  487.        MessageBox (hWnd, "Invalid app handle.", "", MB_OK);
  488.        break;
  489.     case PHONEERR_BADDEVICEID:
  490.        MessageBox (hWnd,"The specified phone device ID is out of range.", "", 
  491.                    MB_OK);
  492.        break;
  493.     case PHONEERR_INCOMPATIBLEAPIVERSION:
  494.        MessageBox (hWnd, "Incompatible API version.", "", MB_OK);
  495.        break;
  496.     
  497.     case PHONEERR_INVALBUTTONLAMPID:
  498.        MessageBox (hWnd, "Invalid Button Lamp ID.", "", MB_OK);
  499.        break;
  500.  
  501.     case PHONEERR_INVALBUTTONMODE:
  502.        MessageBox (hWnd, "Invalid Button Mode.", "", MB_OK);
  503.        break;
  504.  
  505.     case PHONEERR_INVALBUTTONSTATE:
  506.        MessageBox (hWnd, "Invalid Button State", "", MB_OK);
  507.        break;
  508.  
  509.     case PHONEERR_INUSE:
  510.        MessageBox (hWnd, "Phone in Use.", "", MB_OK);
  511.        break;
  512.     
  513.     case PHONEERR_INVALHOOKSWITCHDEV:
  514.        MessageBox (hWnd, "Invalid Hookswitch Device.", "", MB_OK);
  515.        break;
  516.  
  517.     case PHONEERR_INVALHOOKSWITCHMODE:
  518.        MessageBox (hWnd, "Invalid Hookswitch Device Mode.", "", MB_OK);
  519.        break;
  520.  
  521.     case PHONEERR_INVALLAMPMODE:
  522.        MessageBox (hWnd, "Invalid Lamp Mode.", "", MB_OK);
  523.        break;
  524.      
  525.     case PHONEERR_INCOMPATIBLEEXTVERSION:
  526.        MessageBox (hWnd, "Incompatible extension version.","", MB_OK);
  527.        break;
  528.     case PHONEERR_NOMEM:
  529.        MessageBox (hWnd, "No memory","", MB_OK);
  530.        break;
  531.     case PHONEERR_NODRIVER:
  532.        MessageBox (hWnd, "No driver loaded", "", MB_OK);
  533.        break;
  534.     case PHONEERR_RESOURCEUNAVAIL:
  535.        MessageBox (hWnd, "Resource overcommittment", "", MB_OK);
  536.        break;
  537.     case PHONEERR_ALLOCATED:
  538.        MessageBox (hWnd, "Allocation error", "", MB_OK);
  539.        break;
  540.     case PHONEERR_INVALDATAID:
  541.        MessageBox (hWnd, "The data ID is out of range.", "", MB_OK);
  542.        break;
  543.     case PHONEERR_INVALDEVICECLASS:
  544.        MessageBox (hWnd, "The device class was invalid.", "", MB_OK);
  545.        break;
  546.     case PHONEERR_INVALPOINTER:
  547.        MessageBox (hWnd, "The specified pointer parameter is invalid.",
  548.                    "", MB_OK);
  549.        break;
  550.     case PHONEERR_OPERATIONFAILED:
  551.        MessageBox (hWnd, "Operation failed.", "", MB_OK);
  552.        break;
  553.     case PHONEERR_INVALPHONEHANDLE:
  554.        MessageBox (hWnd, "Invalid phone handle", "", MB_OK);
  555.        break;
  556.     case PHONEERR_INVALPHONESTATE :
  557.        MessageBox (hWnd, "Invalid call state for this function.", "", MB_OK);
  558.        break;
  559.     case PHONEERR_INVALPRIVILEGE:
  560.        MessageBox (hWnd, "Invalid privilege for this function.", "", MB_OK);
  561.        break;
  562.     case PHONEERR_NODEVICE:
  563.        MessageBox (hWnd, "No associated device for given class",
  564.                    "", MB_OK);
  565.        break;
  566.     case PHONEERR_OPERATIONUNAVAIL:
  567.        MessageBox (hWnd, "The operation is unavailable",
  568.                    "", MB_OK);
  569.        break;
  570.     case PHONEERR_INVALPARAM:
  571.         MessageBox(hWnd, "Invalid Paramater", "", MB_OK);
  572.        break; 
  573.  
  574.     case PHONEERR_INVALRINGMODE:
  575.             MessageBox(hWnd, "Invalid Ring Mode", "", MB_OK);
  576.        break; 
  577.  
  578.     }
  579.     
  580.              
  581. }
  582.  
  583. LRESULT CALLBACK About( HWND hDlg,           
  584.                         UINT message,        
  585.                         WPARAM wParam,       
  586.                         LPARAM lParam)
  587. {
  588.    switch (message) 
  589.    {
  590.        case WM_INITDIALOG: 
  591.                return (TRUE);
  592.  
  593.        case WM_COMMAND:                              
  594.                if (   LOWORD(wParam) == IDOK         
  595.                    || LOWORD(wParam) == IDCANCEL)    
  596.                {
  597.                        EndDialog(hDlg, TRUE);        
  598.                        return (TRUE);
  599.                }
  600.                break;
  601.    }
  602.  
  603.    return (FALSE); 
  604. }
  605.  
  606.  
  607.  
  608.  
  609.  
  610.  
  611.  
  612.  
  613.